import Vue from 'vue'
import Router from 'vue-router'
import _import from '@/router/_import'
import Layout from '@/views/layout/Layout'


Vue.use(Router)

export const ShopRouterMap = [
    { path: '/login', name: '登陆', component: _import('pages/Login') },            //不用
    { path: '/register', name: '注册', component: _import('pages/Register') },      //不用
    { path: '/forget', name: '忘记密码', component: _import('pages/Forget') },      //不用
    { path: '/myinfo', name: '账号信息', component: _import('pages/MyInfo') },      
    { path: '/banding', name: '绑定手机号', component: _import('pages/Banding') },

    {
        path: '*',
        component: Layout,
        redirect: '/home',
        children: [
            {
                path: 'home',
                name: '香飘飘微商',
                component: _import('home/index'),
                meta: {tabbarIndex: 0}
            }
        ]
    },
    {
        path: '/user',
        component: Layout,
        redirect: '/user/index',
        children: [
            {
                path: 'index',
                name: '我的',
                component: _import('user/index'),
                meta: {tabbarIndex: 3}
            }
        ]
    }
    
]

const router = new Router({
    routes: ShopRouterMap
})

router.beforeEach((to, from, next) => {
    const title = to.name
    if (title) {
        document.title = title;
    }
    next();
});

export {
    router
}
